import React, { Component } from 'react';
import { connect } from 'react-redux';
import {SELECT_ALL} from './store/types'
class Footer extends Component {
  render() {
    return (
      <div className='footer'>
        <div>
          <input type="checkbox" checked={this.props.isAll} onChange={(e)=>{
            this.props.changeAll(e.target.checked)
          }} />
          全选
        </div>
        <span> {this.props.selectCount} / {this.props.todoList.length} </span>
      </div>
    );
  }
}

export default connect((state)=>{
  return {
    selectCount: state.todo.selectCount,
    isAll: state.todo.isAll,
    todoList: state.todo.todoList
  }
}, (dis)=>{
  return {
    changeAll(value){
      dis({type: SELECT_ALL, payload: value})
    }
  }
})(Footer);
